
import 'package:fyi/model/login_model.dart';
import 'package:fyi/net/http_client.dart';
import 'package:fyi/utils/common_util.dart';

class LoginDao{
  static Future<LoginModel> fetch(String username,String password) async {
    var result = await HttpClient.post("Driver/login",data: {"username":username,"password":password});
    print('result : ${result}');
    if(result?.isSuccess()){
      var data = result.data;
      print('data : ${data}');
      if(data != null){
        var model = LoginModel.fromJson(data);
        return model;
      }
    }else{
      CommonUtil.toast(result.getMessage());
      return null;
    }
    throw Exception('登录失败');
  }
}